package com.gitee.cui.client.builder;

import com.gitee.cui.client.client.ClientSession;
import com.gitee.cui.common.common.bean.User;
import com.gitee.cui.common.common.bean.msg.ProtoMsg;

/**
 * 心跳信息构建器
 * @author cuiqingqiang
 * @version 1.0
 * @date 2021/10/27 15:39
 **/
public class HeartBeatMsgBuilder extends BaseBuilder {

    /**
     * 用户信息
     */
    private User user;

    public HeartBeatMsgBuilder (User user, ClientSession session) {
        super(ProtoMsg.HeadType.HEART_BEAT, session);
        this.user = user;
    }

    public ProtoMsg.Message buildMsg() {
        ProtoMsg.Message message = buildCommon(-1);
        ProtoMsg.MessageHeartBeat.Builder hb = ProtoMsg.MessageHeartBeat.newBuilder()
                .setSeq(0)
                .setJson("{\"from\":\"client\"}")
                .setUid(user.getUid());
        return message.toBuilder().setHeartBeat(hb).build();
    }
}
